ostree_repo_sign_delta
ostree_repo_has_object
ostree_repo_mark_commit_partial
+ostree_repo_mark_commit_partial_reason
ostree_repo_write_metadata
ostree_repo_write_metadata_async
ostree_repo_write_metadata_finish
/* Add new symbols here. Release commits should copy this section into -released.sym. */
LIBOSTREE_2019.4 {
+ ostree_repo_mark_commit_partial_reason;
} LIBOSTREE_2019.3;
/* Stub section for the stable release *after* this development one; don't
}
/**
- * ostree_repo_mark_commit_partial:
+ * ostree_repo_mark_commit_partial_reason:
* @self: Repo
* @checksum: Commit SHA-256
* @is_partial: Whether or not this commit is partial
+ * @in_state: Reason bitmask for partial commit
* @error: Error
*
- * Commits in "partial" state do not have all their child objects written. This
- * occurs in various situations, such as during a pull, but also if a "subpath"
- * pull is used, as well as "commit only" pulls.
+ * Allows the setting of a reason code for a partial commit. Presently
+ * it only supports setting reason bitmask to
+ * OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL, or
+ * OSTREE_REPO_COMMIT_STATE_NORMAL. This will allow successive ostree
+ * fsck operations to exit properly with an error code if the
+ * repository has been truncated as a result of fsck trying to repair
+ * it.
*
- * This function is used by ostree_repo_pull_with_options(); you
- * should use this if you are implementing a different type of transport.
- *
- * Since: 2017.15
+ * Since: 2019.4
*/
gboolean
-ostree_repo_mark_commit_partial (OstreeRepo *self,
- const char *checksum,
- gboolean is_partial,
- GError **error)
+ostree_repo_mark_commit_partial_reason (OstreeRepo *self,
+ const char *checksum,
+ gboolean is_partial,
+ OstreeRepoCommitState in_state,
+ GError **error)
{
g_autofree char *commitpartial_path = _ostree_get_commitpartial_path (checksum);
if (is_partial)
if (errno != EEXIST)
return glnx_throw_errno_prefix (error, "open(%s)", commitpartial_path);
}
+ else
+ {
+ if (in_state & OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL)
+ if (glnx_loop_write (fd, "f", 1) < 0)
+ return glnx_throw_errno_prefix (error, "write(%s)", commitpartial_path);
+ }
}
else
{
return TRUE;
}
+/**
+ * ostree_repo_mark_commit_partial:
+ * @self: Repo
+ * @checksum: Commit SHA-256
+ * @is_partial: Whether or not this commit is partial
+ * @error: Error
+ *
+ * Commits in the "partial" state do not have all their child objects
+ * written. This occurs in various situations, such as during a pull,
+ * but also if a "subpath" pull is used, as well as "commit only"
+ * pulls.
+ *
+ * This function is used by ostree_repo_pull_with_options(); you
+ * should use this if you are implementing a different type of transport.
+ *
+ * Since: 2017.15
+ */
+gboolean
+ostree_repo_mark_commit_partial (OstreeRepo *self,
+ const char *checksum,
+ gboolean is_partial,
+ GError **error)
+{
+ return ostree_repo_mark_commit_partial_reason (self, checksum, is_partial,
+ OSTREE_REPO_COMMIT_STATE_NORMAL,
+ error);
+}
+
/**
* ostree_repo_transaction_set_refspec:
* @self: An #OstreeRepo
g_autofree char *commitpartial_path = _ostree_get_commitpartial_path (sha256);
*out_state = 0;
- if (!glnx_fstatat_allow_noent (self->repo_dir_fd, commitpartial_path, NULL, 0, error))
+ glnx_autofd int fd = -1;
+ if (!ot_openat_ignore_enoent (self->repo_dir_fd, commitpartial_path, &fd, error))
return FALSE;
- if (errno == 0)
- *out_state |= OSTREE_REPO_COMMIT_STATE_PARTIAL;
+ if (fd != -1)
+ {
+ *out_state |= OSTREE_REPO_COMMIT_STATE_PARTIAL;
+ char reason;
+ if (read (fd, &reason, 1) == 1)
+ {
+ if (reason == 'f')
+ *out_state |= OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL;
+ }
+ }
}
}
else if (self->parent_repo)
GKeyFile *new_config,
GError **error);
+/**
+ * OstreeRepoCommitState:
+ * @OSTREE_REPO_COMMIT_STATE_NORMAL: Commit is complete. This is the default.
+ * (Since: 2017.14.)
+ * @OSTREE_REPO_COMMIT_STATE_PARTIAL: One or more objects are missing from the
+ * local copy of the commit, but metadata is present. (Since: 2015.7.)
+ * @OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL: One or more objects are missing from the
+ * local copy of the commit, due to an fsck --delete. (Since: 2019.3.)
+ *
+ * Flags representing the state of a commit in the local repository, as returned
+ * by ostree_repo_load_commit().
+ *
+ * Since: 2015.7
+ */
+typedef enum {
+ OSTREE_REPO_COMMIT_STATE_NORMAL = 0,
+ OSTREE_REPO_COMMIT_STATE_PARTIAL = (1 << 0),
+ OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL = (1 << 1),
+} OstreeRepoCommitState;
+
/**
* OstreeRepoTransactionStats:
* @metadata_objects_total: The total number of metadata objects
gboolean is_partial,
GError **error);
+_OSTREE_PUBLIC
+gboolean ostree_repo_mark_commit_partial_reason (OstreeRepo *self,
+ const char *checksum,
+ gboolean is_partial,
+ OstreeRepoCommitState in_state,
+ GError **error);
+
_OSTREE_PUBLIC
void ostree_repo_transaction_set_refspec (OstreeRepo *self,
const char *refspec,
GVariant **out_variant,
GError **error);
-/**
- * OstreeRepoCommitState:
- * @OSTREE_REPO_COMMIT_STATE_NORMAL: Commit is complete. This is the default.
- * (Since: 2017.14.)
- * @OSTREE_REPO_COMMIT_STATE_PARTIAL: One or more objects are missing from the
- * local copy of the commit, but metadata is present. (Since: 2015.7.)
- *
- * Flags representing the state of a commit in the local repository, as returned
- * by ostree_repo_load_commit().
- *
- * Since: 2015.7
- */
-typedef enum {
- OSTREE_REPO_COMMIT_STATE_NORMAL = 0,
- OSTREE_REPO_COMMIT_STATE_PARTIAL = (1 << 0),
-} OstreeRepoCommitState;
-
_OSTREE_PUBLIC
gboolean ostree_repo_load_commit (OstreeRepo *self,
const char *checksum,
if ((state & OSTREE_REPO_COMMIT_STATE_PARTIAL) == 0)
{
g_printerr ("Marking commit as partial: %s\n", parent_commit);
- if (!ostree_repo_mark_commit_partial (repo, parent_commit, TRUE, error))
+ if (!ostree_repo_mark_commit_partial_reason (repo, parent_commit, TRUE, OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL, error))
return FALSE;
}
}
opt_verify_bindings = TRUE;
guint n_partial = 0;
+ guint n_fsck_partial = 0;
g_hash_table_iter_init (&hash_iter, objects);
while (g_hash_table_iter_next (&hash_iter, &key, &value))
{
}
if (commitstate & OSTREE_REPO_COMMIT_STATE_PARTIAL)
- n_partial++;
+ {
+ n_partial++;
+ if (commitstate & OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL)
+ n_fsck_partial++;
+ }
else
g_hash_table_add (commits, g_variant_ref (serialized_key));
}
if (found_corruption)
return glnx_throw (error, "Repository corruption encountered");
+ if (n_fsck_partial > 0)
+ return glnx_throw (error, "%u fsck deleted partial commits not verified", n_partial);
+
return TRUE;
}